/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __37F9D32B_31F4_455b_BEDD_5E9BE1EF8F71__
#define __37F9D32B_31F4_455b_BEDD_5E9BE1EF8F71__

#include "include_odbc.h"
#include "err_info.h"

namespace xos_odbc
{

    class mgr : public i_odbc_mgr
    {
    public:
        typedef xos::release_impl< mgr > T;

    public:
        mgr();
        ~mgr();

    public:
        static int static_init( xos_container::i_container* pContainer, i_odbc_mgr** ppv );
        static xos_container::i_container* container();
        static mgr* get();

    public:
        int connect( void * hWnd, const char * lpszConnectStr, i_connect ** ppDbc );
        i_connect_pool * connect_pool( const char * lpszConnectStr );

    public:
        int put_back_to_pool();
        int init();
        int term();

    private:
        int create_connect( void * hWnd, const char * lpszConnectStr, i_connect ** ppDbc );
        int init_data();
        int init_env();
        int term_env();

    private:
        SQLHANDLE m_hEnv;
		err_info m_err;

    };

} // xos_odbc

#endif // __37F9D32B_31F4_455b_BEDD_5E9BE1EF8F71__
